//package com.mo.lib.view.chart;
//
///**
// * @ author：mo
// * @ data：2022/8/24:15:46
// * @ 功能：
// */
//public class aaa {
//}
//    //初始化水平柱状图
//    HorizontalBarChart horizontalBarChart = findViewById(R.id.horizontalBarChart);
//    initBarChart(horizontalBarChart);
//horizontalBarChart.setData(setBarData());
//        barChart.invalidate();
//
//public BarChart initBarChart(BarChart barChart) {
//        barChart.setDrawBarShadow(false); // 设置每条柱子的阴影不显示
//        barChart.setDrawValueAboveBar(true); // 设置每条柱子的数值显示
//        barChart.setPinchZoom(false);
//        XAxis xAxis = barChart.getXAxis(); // 获取柱状图的x轴
//        YAxis yAxisLeft = barChart.getAxisLeft(); // 获取柱状图左侧的y轴
//        YAxis yAxisRight = barChart.getAxisRight(); // 获取柱状图右侧的y轴
//        setAxis(xAxis, yAxisLeft, yAxisRight); //调用方法设置柱状图的轴线
//        return barChart;
//        }
//
//public BarData setBarData() {
//        List<BarEntry> entries = new ArrayList<>(); //定义一个数据容器
//        //生成随机数数据
//        for (int i = 0; i <= 12; i++) {
//        entries.add(new BarEntry(i, new Random().nextInt(300)));
//        }
//        BarDataSet barDataSet = new BarDataSet(entries, "测试数据");
//        BarData barData = new BarData(barDataSet);
//        return barData; //返回可用于柱状图的数据
//        }
////public class HBar_test extends Fragment {
////
////    private HorizontalBarChart hc;
////
////    @Nullable
////    @Override
////    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
////        return inflater.inflate(R.layout.hc,null);
////    }
////
////    @Override
////    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
////        super.onViewCreated(view, savedInstanceState);
////
////        hc = view.findViewById(R.id.hc);
////
////        setDes();
////
////        setXAxis();
////
////        setYAxis();
////
////        loadData();
////    }
////
////    //设置标题
////    private void setDes() {
////        Description description = new Description();
////        description.setText("违章车辆的违章次数占比分布图统计");
////        description.setTextSize(20f);
////        description.setTextColor(Color.BLACK);
////
////        //获取屏幕的中间坐标
////        WindowManager wm = (WindowManager) getActivity() .getSystemService(Context.WINDOW_SERVICE);
////        DisplayMetrics dm = new DisplayMetrics();
////        wm.getDefaultDisplay().getMetrics(dm);
////        float x = dm.widthPixels / 2;
////
////        description.setPosition(x,40);
////        hc.setDescription(description);
////    }
////
////    //设置y轴
////    private void setYAxis() {
////        //两边的y轴都要设置y轴的最小值才能在柱状图上面显示数值
////        //不然是看不到效果的
////        YAxis tepAxis = hc.getAxisLeft();
////        tepAxis.setAxisMaximum(80f);
////        tepAxis.setAxisMinimum(0f);
////        tepAxis.setEnabled(false);
////
////        YAxis yAxis = hc.getAxisRight();
////        yAxis.setTextSize(12f);
////        yAxis.setAxisMinimum(0f);
////        yAxis.setAxisMaximum(80f);
////        //自定义样式
////        yAxis.setValueFormatter(new IAxisValueFormatter() {
////            @Override
////            public String getFormattedValue(float value, AxisBase axis) {
////                return value + "0%";
////            }
////        });
////    }
////
////    //设置x轴
////    private void setXAxis() {
////        XAxis xAxis = hc.getXAxis();
////        xAxis.setTextSize(16);
////        xAxis.setAxisMaximum(2.6f);
////        //把最小值设置为负数能够为下方留出点空白距离
////        xAxis.setAxisMinimum(-0.6f);
////        xAxis.setDrawGridLines(false);
////        //将x轴显示在左侧
////        xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
////        xAxis.setLabelCount(3);
////        //自定义样式
////        final String ss[] = {"5条以上违章","3-5条违章","1-2条违章"};
////        xAxis.setValueFormatter(new IAxisValueFormatter() {
////            @Override
////            public String getFormattedValue(float value, AxisBase axis) {
////                return ss[(int) value];
////            }
////        });
////        //设置x轴的偏移量
////        xAxis.setXOffset(15f);
////    }
////
////    //加载数据
////    private void loadData() {
////        //不绘制图例
////        hc.getLegend().setEnabled(false);
////        //自动对齐
////        hc.setFitBars(true);
////        hc.setExtraOffsets(20,50,30,30);
////        //将文本绘制在柱块上还是柱块里面
////        hc.setDrawValueAboveBar(true);
////
////        //从下往上绘制
////        final List<BarEntry> entries = new ArrayList<BarEntry>();
////        float da[] = {60.51f,26.28f,13.20f};
////
////        for(int i = 0; i < da.length; i++){
////            entries.add(new BarEntry(i,da[i]));
////        }
////
////        BarDataSet barDataSet = new BarDataSet(entries,"");
////        barDataSet.setValueTextSize(16f);//柱块上的字体大小
////        barDataSet.setValueTextColor(Color.RED);//柱块上的字体颜色
////        barDataSet.setValueTypeface(Typeface.DEFAULT_BOLD);//加粗
////        //自自定义样式
////        barDataSet.setValueFormatter(new IValueFormatter() {
////            @Override
////            public String getFormattedValue(float value, Entry entry, int dataSetIndex, ViewPortHandler viewPortHandler) {
////                return String.format("%.2f",value) + "%";//保留两位小数
////            }
////        });
////        //依次设置每次柱块的颜色
////        barDataSet.setColors(getResources().getColor(R.color.h_green),getResources().getColor(R.color.h_bule),getResources().getColor(R.color.h_red));
////        BarData barData = new BarData(barDataSet);
////        //设置柱块的宽度
////        barData.setBarWidth(0.4f);
////
////        hc.setData(barData);
////
////    }
//
